import { appFetch } from "@/utils/appFetch";

export const loginApi = (
  loginInfo: {
    username: string,
    password: string
  }
) => appFetch(
  '/api/login',
  {
    method: 'post',
    body: JSON.stringify(loginInfo)
  }
)

export const registerApi = (
  loginInfo: {
    username: string,
    password: string
  }
) => appFetch(
  '/api/register',
  {
    method: 'post',
    body: JSON.stringify(loginInfo)
  }
)

/**
 * 获取用户信息
 * @returns 用户信息
 */
export const getCurrentUserInfoApi = () => appFetch(
  '/api/getCurrentUserInfo',
  {
    method: 'get',
  }
)

export const updateUserAppConfigApi = (
  _id: string,
  appConfig: any
) => appFetch(
  `/api/users/updateUser/${_id}`,
  {
    method: 'put',
    body: JSON.stringify({ appConfig })
  }
)